capture log close
cd "C:\Research\Legal Services Corporation\"

log using "summary_statistics.txt", text replace

use "acs_small2008.dta", clear
  
foreach year in "09" "10" "11" "12" "13" "14" "15" "16" "17" {
  append using "acs_small20`year'.dta"
}

drop if cit==5 | mil==1


recode mig (1=0) (2 3=1), gen(moved)

gen rent=ten==3 if ten!=.

recode hisp (1=0) (2/24=1), gen(hispanic)

gen english=eng==1 | eng==2 if eng!=.

gen black=rac1p==2 if rac1p!=.
gen white=rac1p==1 & !hispanic if rac1p!=. & hispanic!=.

gen english_only=lanx==2 if lanx!=.
gen married=mar==1 if mar!=.
gen male=sex==1 if sex!=.
gen unemployed=esr==3 if esr!=.
gen disabled=dis==1 if dis!=.

recode schl (1 2 3=0) (4=1) (5=2) (6=3) (7=4) (8=5) (9=6) (10=7) (11=8) (12=9) (13=10) (14=11) (15 16 17 18=12) (19 20=14) (21=16) (22=18) (23=19) (24=20), gen(yrsschl)

local varlist="white black hispanic age male yrsschl english_only unemployed disabled"

matrix results=J(20,3,.)
matrix rownames results=`varlist' N

foreach var in `varlist' {
	quietly sum `var' if (povpip>=120 & povpip<=124) & rent==1
	matrix results[rownumb(results, "`var'"),1]=r(mean)
	quietly sum `var' if (povpip>=125 & povpip<=129) & rent==1
	matrix results[rownumb(results, "`var'"),2]=r(mean)	
	matrix results[rownumb(results, "`var'"),3]=(results[rownumb(results, "`var'"),2]-results[rownumb(results, "`var'"),1])/results[rownumb(results, "`var'"),1]
}

quietly sum sex if (povpip>=120 & povpip<=124) & rent==1
matrix results[rownumb(results, "N"),1]=r(N)
quietly sum sex if (povpip>=125 & povpip<=129) & rent==1
matrix results[rownumb(results, "N"),2]=r(N)

matrix list results


log close

